﻿
<?php
	/*查询所有的学生表格*/
 	('Access-Control-Allow-Origin：*');
	include("mysql.php");
	$searchName = $_REQUEST['searchName'];
    $searchCardid = $_REQUEST['searchCardid'];
    $searchSchool = $_REQUEST['searchSchool'];
    $condition = $_REQUEST['condition'];
    $searchTeacher = $_REQUEST['searchTeacher'];
    $ispay = $_REQUEST['ispay'];
    $isBao = $_REQUEST['isBao'];
    $scale = $_REQUEST['scale'];
    $userid = $_REQUEST['userid'];
    $createtime = $_REQUEST['createtime'];
    $province = $_REQUEST['province'];
    $tiaoshu = $_REQUEST['tiaoshu'];
    $searchUnifiedExam = $_REQUEST['searchUnifiedExam'];
    $searchPaper = $_REQUEST['searchPaper'];
    $searchBaccalaureate = $_REQUEST['searchBaccalaureate'];
    $sql="select s.Refund,s.isRefund,s.id,s.name,s.phone,s.cardid,s.cengci,s.mail,s.sosperson,s.sosphone,t.tname,s.school,s.major,s.money,s.ispay,s.creattime,s.educationType,s.remarks,s.isTi,s.oweafee,s.isBao,s.unifiedExam,s.paper,s.baccalaureate from students s INNER JOIN teachers t ON s.tid = t.id where s.name like '%{$searchName}%' and s.cardid like '%{$searchCardid}%' and s.isBao like '%{$isBao}%' and s.school like '%{$searchSchool}%' and t.tname like '%{$searchTeacher}%' and s.ispay like '%{$ispay}%' and s.creattime like '%{$createtime}%' and s.unifiedExam like '%{$searchUnifiedExam}%' and s.paper like '%{$searchPaper}%' and s.baccalaureate like '%{$searchBaccalaureate}%'";
    //LEFT(`cardid`,6) NOT BETWEEN 230000 AND 239999 不是黑龙江省身份证号码

  if ($province == "1") {
    $sql .=" and LEFT(`cardid`,6) BETWEEN 230000 AND 239999";
  }else if($province == "2"){
    $sql .=" and LEFT(`cardid`,6) NOT BETWEEN 230000 AND 239999";
  }

   if($scale==1){
    
    }
    else  if($scale==2){
    	$sql .= "and s.isTi like '1'";
    }
    else if($scale==3){
    	$sql .= "and s.tid  = '{$userid}'";
    }
    else if($scale==4){

    }else if($scale==5){
    	$sql .= "and s.tid  = '{$userid}'";
    }
    if($condition==0){
	    	$sql .= " order by s.id desc";
    }
   else{
   	    $sql .= " and s.educationType = '{$condition}' order by s.id desc";
   } /*创建新的连接对象并使用new 对象的方法*/
  if($tiaoshu>0){
  	$sql .="  limit 0,{$tiaoshu}";
  }
  else{
  	
  }

    $Mysql = new Mysql();
    /*查询表格参数一表明   参数二 查询语句*/
	$arrsd = $Mysql->likeSelectLayui($sql);
	/*返回出去*/
	if(is_array($arrsd)==1){
		$msg = [
	      'code' => 200,
	      'msg' => '查询成功',
	      'data'=> $arrsd,
	      'count' => count($arrsd)
	   ];
	}
	else{
		$msg = [
	      'msg' => '没有查到数据',
	     
	   ];
	}
	
    echo json_encode($msg);
	/*关闭连接*/
    $Mysql->close();

?>